class Solution 
{
public:
    int takeAttendance(vector<int>& records) 
    {
        // 二分解法
        int left = 0, right = records.size() - 1;
        while(left < right)
        {
            int mid = left + (right - left) / 2;
            if(records[mid] == mid) left = mid + 1; 
            else right = mid;
        }
        // 返回值的时候，注意处理细节问题
        return records[left] == left ? left + 1 : left;
    }
};